﻿<%@ Page CodeFileBaseClass="AliCMS.Lib.SystemPageBase" %>
<script language="c#" runat="server">
protected string Condition()
{
	StringBuilder condition = new StringBuilder();
	string and = String.Empty;

	#region 是否审核
	string isChecked = Request.QueryString["IsChecked"];
	if (isChecked == null)
		condition.Append(and + Alias.Link.IsChecked + "=true");
	else if (isChecked != String.Empty)
		condition.Append(and + Alias.Link.IsChecked + "=" + isChecked);
	#endregion

	if (and == String.Empty && condition.Length != 0)
		and = " AND ";

	#region 类别
	string categoryID = Request.QueryString["CategoryID"];
	if (!String.IsNullOrEmpty(categoryID))
	{
		if (Convert.ToBoolean(Request.QueryString["IncludeSubCategory"]))
		{
			condition.Append(and + Alias.Link.IncludeSubCategory + "=" + categoryID);
		}
		else
		{
			if (categoryID == "0")
				condition.Append(and + Alias.Link.CategoryID + " IS NULL");
			else
				condition.Append(and + Alias.Link.CategoryID + "=" + categoryID);
		}
	}
	#endregion

	if (and == String.Empty && condition.Length != 0)
		and = " AND ";

	#region 关键词
	string keyword = Request.QueryString["Keyword"];
	if (!String.IsNullOrEmpty(keyword))
	{
		switch (Request.QueryString["KeywordType"])
		{
			case "Name":
				condition.Append(and + Alias.Link.Name + " LIKE '%" + keyword + "%'");
				break;
			case "URL":
				condition.Append(and + Alias.Link.URL + " LIKE '%" + keyword + "%'");
				break;
			case "Email":
				condition.Append(and + Alias.Link.Email + " LIKE '%" + keyword + "%'");
				break;
			case "QQ":
				condition.Append(and + Alias.Link.QQ + " LIKE '%" + keyword + "%'");
				break;
			case "Phone":
				condition.Append(and + Alias.Link.Phone + " LIKE '%" + keyword + "%'");
				break;
		}
	}
	#endregion
	
	return condition.ToString();
}

protected string Sort()
{
	string sort = String.Empty;
	switch (Request.QueryString["Sort"])
	{
		case "1":
			sort = Alias.Link.Sort + " ASC";
			break;
		case "2":
			sort = Alias.Link.InnerID + " DESC";
			break;
		case "3":
			sort = Alias.Link.InnerID + " ASC";
			break;
		default:
			sort = Alias.Link.Sort + " ASC";
			break;
	}
	
	return sort;
}
</script>
<section data-page="link_list" data-title="链接列表" data-lang="<%=ContentLang%>">
	<dl class="path1">
		<dt><span>您的位置：</span>链接列表</dt>
		<dd>
			<select data-class="<%=ContentLang%>Font" data-ali-widget="combo">
				<ali:List Object="Language" Source="Manager.Languages">
					<ali:Record>
						<%If Convert.ToString(Ab) == ContentLang%>
							<option value="<%=Ab%>" selected><%=[AliCMS.SystemModule.Alias.Language.Name + PageLang]%></option>
						<%Else%>
							<option value="<%=Ab%>"><%=[AliCMS.SystemModule.Alias.Language.Name + PageLang]%></option>
						<%EndIf%>
					</ali:Record>
				</ali:List>
			</select>
		</dd>
	</dl>
	<div class="ali-tabs sub-nav" data-height-style="fill" data-event="click">
		<div class="ali-tabs-header">
			<div class="ali-tabs-nav-container">
				<ul>
					<li class="ali-active"><a>链接列表</a></li>
					<li><a href="add.aspx?Lang=<%=ContentLang%>" target="ali-navtab">添加链接</a></li>
					<li><a href="../link_category/list.aspx?Lang=<%=ContentLang%>" target="ali-navtab">类别列表</a></li>
					<li><a href="../link_category/add.aspx?Lang=<%=ContentLang%>" target="ali-navtab">添加类别</a></li>
				</ul>				
			</div>
		</div>
		<div class="ali-tabs-body">
			<div class="ali-tabs-panel">
				<form action="?Lang=<%=ContentLang%>" class="search1">
 					<select name="IsChecked" data-class="<%=ContentLang%>Font" data-ali-widget="combo">
						<option value="">是否审核</option>
						<option value="false">未审核</option>
						<option value="true" selected="selected">已审核</option>
					</select>
					<select name="CategoryID" data-class="<%=ContentLang%>Font" data-tree="true" data-root="" data-ali-widget="combo">
						<option data-item="" data-parent="" value="">未指定</option>
						<option data-item="" data-parent="" value="0">未指定类别</option>
						<ali:Tree Object="LinkCategory">
							<ali:Record>
								<%If Convert.ToString(ID) == Request.QueryString["CategoryID"]%>
									<option data-item="<%=InnerID%>" data-parent="<%=ParentInnerID%>" value="<%=ID%>" selected><%=Name%></option>
								<%Else%>
									<option  data-item="<%=InnerID%>" data-parent="<%=ParentInnerID%>" value="<%=ID%>"><%=Name%></option>
								<%EndIf%>
								<%=ChildRecords%>
							</ali:Record>
						</ali:Tree>		
					</select>
					<label><input type="checkbox" name="IncludeSubCategory" class="ali-input <%=ContentLang%>Font">子类</label>
                   <select name="Sort" data-class="<%=ContentLang%>Font" data-ali-widget="combo">
                        <option value="1">手动</option>
                        <option value="2">编号↓</option>
                        <option value="3">编号↑</option>
                    </select>
                    <input name="Keyword" class="ali-input <%=ContentLang%>Font" >
					<select name="KeywordType" data-class="<%=ContentLang%>Font" data-ali-widget="combo">
						<option value="Name">名称</option>
						<option value="URL">网址</option>
						<option value="Email">Email</option>
						<option value="QQ">QQ</option>
						<option value="Phone">电话</option>
					</select>
					<button type="submit" class="ali-button">搜索</button>
				</form>
				<ul class="toolbar1">
					<li class="select-all"><a><span>全选</span></a></li>
					<li class="select-reverse"><a><span>反选</span></a></li>
			
					<li class="delete" data-operation="Delete"><a><span>删除</span></a></li>
					<li class="check" data-operation="Check"><a><span>审核</span></a></li>
					<li class="uncheck" data-operation="UnCheck"><a><span>取消审核</span></a></li>
				</ul>
				<div class="content">
					<table data-ali-widget="grid" class="grid1">
						<thead>
							<tr>
								<th width="50">移动</th>
								<th width="200">LOGO</th>
								<th>名称</th>
								<th>网址</th>
								<th width="80">QQ</th>
								<th width="80">删除</th>
							</tr>
						</thead>
						<tbody>
                            <ali:List ID="List" Object="Link" Page="PageNumber" PageSize="PageSizeValue" Condition="Condition()" Sort="Sort()" Validate="True">
                                <ali:Record>
                                    <tr data-id="<%=InnerID%>">
                                         <td data-sort="<%=InnerID%>" data-name="<%=Name%>"><%=InnerID%></td>
										<td>
											<%If Convert.ToString(Logo) != String.Empty%>
												<a href="<%=URL%>" target="_blank"><img src="<%=Logo%>" width="88" height="31" /></a>
											<%EndIf%>
										</td>
										<td class="<%=ContentLang%>Font"><a href="edit.aspx?Lang=<%=ContentLang%>&amp;ID=<%=InnerID%>" target="ali-navtab"><%=Name%></a></td>
										<td><%=URL%></td>
										<td><%=QQ%></td>
										<td><a class="ali-button" data-operation="Delete">删除</a></td>
                                    </tr>
                                </ali:Record>
                            </ali:List>
						</tbody>
					</table>
					<ali:Pagination Page="PageNumber" PageSize="PageSizeValue" RecordCount="List[RecordCount]">
						<div class="pagination1" data-page-number="<%=PageNumber%>" data-page-count="<%=PageCount%>" data-page-size="<%=PageSize%>">
							<div class="pagination1-left">
								共<b><%=PageCount%></b>页，每页显示
									<select name="PageSize" data-ali-widget="combo">
										<option value="20">20</option>
										<option value="50">50</option>
										<option value="100">100</option>
										<option value="200">200</option>
									</select>条，共<b><%=RecordCount%></b>条记录
							</div>
							<ul class="pagination1-right">
								<ali:FirstPage>
									<ali:Yes>
										<li><span><span class="first disabled">首页</span></span></li>
										<li><span><span class="prev disabled">上一页</span></span></li>
									</ali:Yes>
									<ali:No>
										<li><a href="1"><span class="first">首页</span></a></li>
										<li><a href="<%=PageNumber - 1%>"><span class="prev">上一页</span></a></li>
									</ali:No>
								</ali:FirstPage>
								<ali:CurrentPage Range="5">
									<ali:Yes>
										<li class="active"><span><%=Index%></span></li>
									</ali:Yes>
									<ali:No>
										<li><a href="<%=Index%>"><%=Index%></a></li>
									</ali:No>
								</ali:CurrentPage>
								<ali:LastPage>
									<ali:Yes>
										<li><span><span class="next disabled">下一页</span></span></li>
										<li><span><span class="last disabled">末页</span></span></li>
									</ali:Yes>
									<ali:No>
										<li><a href="<%=PageNumber + 1%>"><span class="next">下一页</span></a></li>
										<li><a href="<%=PageCount%>"><span class="last">末页</span></a></li>
									</ali:No>
								</ali:LastPage>
			
								<li class="go">
									<input type="text" name="PageNumber" value="1" size="4"><button></button>
								</li>
							</ul>
						</div>
					</ali:Pagination>
				</div>
			</div>
		</div>
		<div class="ali-tabs-bottom"><b></b></div>
	</div>
</section>